<!-- 我的表格 -->

<template>
  <WebTable class="RepairList-MyTable">
    <RowIndex />

    <RowTitle label="工单编号" bind="orderCode" :width="240" noTip>
      <template #default="{ row, text }">
        <div :class="getTitleClass(row)">{{ text }}</div>
      </template>
    </RowTitle>

    <RowDict label="工单来源" bind="orderSourceId" :dict="CORE.DICT.task_source" />
    <RowDict label="工单类型" bind="orderTypeId" :dict="CORE.DICT.task_type" />
    <RowDict label="子类" bind="orderSubTypeId" :dict="CORE.DICT.task_sub_type" />
    <RowTime label="创建时间" bind="createTime" :minWidth="100" width="auto" />
    <RowText label="创建人" bind="createUserName" />
    <RowText label="提单人" bind="releaseUserName" />
    <RowText label="处理人" bind="resolverUserName" />

    <RowStatus :dict="GETTER.STATUS" :width="150">
      <template #default="{ row, text, props }">
        <div :class="getStatusClass(row)">
          <span v-bind="props">{{ text }}</span>
        </div>
      </template>
    </RowStatus>

    <RowOperate>
      <template #default="{ row }">
        <BtnText title="查看" @click="windowDetail(row)" />

        <BtnText v-if="MAP[row.status].hasRelease" title="发布" @click="openRelease(row)" />
        <BtnText v-if="MAP[row.status].hasRelease" title="删除" red @click="openDelete(row)" />

        <BtnText v-if="MAP[row.status].btn" :title="MAP[row.status].btn" @click="openDeal(row)" />
        <BtnText v-else-if="hasRate(row)" title="评价" @click="openDeal(row)" />

        <BtnText v-if="!MAP[row.status].noCancel" title="撤销" red @click="openCancel(row)" />
      </template>
    </RowOperate>
  </WebTable>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import mixDetailToTable from '@admin/components/detail/mixDetailToTable'
import RepairFooter from '@admin/components/detail/DetailRepair/RepairFooter'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyTable',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [
    mixDetailToTable('', 'DetailRepair'),
    CORE.mixWeb('deal', 'deal_'),
  ],

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    ...RepairFooter.methods,

    /**
     * 获取标题样式类
     */
    getTitleClass(row) {
      const hastenClass = row.hastenStatus > 1 ? ' RepairList-MyTable-hasten' : ''
      const superviseClass = row.checkTimeoutFlag === 1 ? ' RepairList-MyTable-supervise' : ''
      return `RepairList-MyTable-title ${hastenClass}${superviseClass}`
    },

    /**
     * 获取状态样式类
     */
    getStatusClass(row) {
      if (!row.checkTimeoutLevel) return null
      return `DetailRepair-RepairBase-timeout-${row.checkTimeoutLevel}`
    },
  },
}
</script>

<style lang="scss">
@import './index.scss';
</style>
